slide = new JSlider( JSlider.HORIZONTAL, 0, 100, 79 ); slide.setMajorTickSpacing( 10); slide.setMinorTickSpacing( 5);
setPaintTicks
and setPaintLabels
Tick marks and their labels are turned on or off using these methods:
setPaintTicks ( boolean state ) setPaintLabels( boolean state )
Sometimes you want the knob of a slider to stop only at the tick marks so that the value of the slider is an integer multiple of the minor tick spacing. Use this method:
setSnapToTicks( boolean state )
Ask that ticks and labels be displayed as in the picture and that the knob snap to the ticks.